#include "debug.h"
void uart_init(void)
{
    RCC->APB2ENR |= RCC_APB2ENR_USART1EN | RCC_APB2ENR_IOPAEN;
    GPIOA->CRH |= (GPIO_CRH_MODE9 | GPIO_CRH_CNF9_1 | GPIO_CRH_CNF10_0);
    GPIOA->CRH &= ~(GPIO_CRH_CNF9_0 | GPIO_CRH_MODE10 | GPIO_CRH_CNF10_1);
    USART1->BRR = 0x271;
    USART1->CR1 |= USART_CR1_TE;
    USART1->CR1 |= USART_CR1_UE;
}
void uart_transmit(uint8_t byte)
{
    while ((USART1->SR & USART_SR_TXE) == 0)
        ;
    USART1->DR = byte;
}
int fputc(int c, FILE *file)
{
    uart_transmit((uint8_t)c);
    return c;
}
